function init(num) {
    //确定地图大小
    MINENUM = num;
    // 生成地雷
    let content = document.getElementById('body');
    // 删除可能存在的节点
    let btn = content.firstChild;
    while (btn) {
        btn.remove();
        btn = content.firstChild;
    }
    if (document.getElementById('over') !== null) {
        document.getElementById('over').remove();
    }
    if (document.getElementsByClassName('mine-num-box').length === 0) {
        //添加剩余雷的数量
        let div = document.createElement('div')
        div.className = 'mine-num-box';
        div.innerText = '剩余地雷：';

        let num_box = document.createElement('p')
        num_box.id = 'num-box';
        num_box.safeBox = 0;
        num_box.innerText = 0;
        div.appendChild(num_box);
        document.getElementsByClassName('nav')[0].appendChild(div)
    }
    else {
        document.getElementById('num-box').innerText = 0;
    }

    //添加按钮
    const arr = createMine(num);
    for (let i = 0; i < num; i++) {
        let row = document.createElement('div')
        for (let j = 0; j < num; j++) {
            const temp = document.createElement('button')
            temp.className = 'mine init iconfont icon-kongbai'
            temp.onmouseup = function (e) {
                if (e.button === 0) {
                    //鼠标左键
                    getClick(this);
                }
                else if (e.button === 2) {
                    //鼠标右键
                    getFlag(this);
                }
            }
            //给地雷添加行列信息
            temp.id = (i + 1) * 100 + j + 1;
            if (arr[i][j] === 1) {      //给方块放置地雷信息
                temp.mine = true;
            }
            else {
                temp.mine = false;
            }
            row.appendChild(temp)
        }
        content.appendChild(row)
    }

    //开始计时
    let nav = document.getElementsByClassName('nav')[0];
    nav.startTime = new Date().getTime();
}